#include "pwm.h"
#include <wiringPi.h>
#include <softPwm.h>

// 公式：int softPwmCreate(int pin, int initialValue, int pwmRange);
void pwm_write(int pwm_pin)
{
    pinMode(pwm_pin,OUTPUT);
    softPwmCreate(pwm_pin,0,200); // 将range设置为200步，周期则为20ms
    softPwmWrite(pwm_pin,10);
    delay(1000);
    softPwmStop(pwm_pin);
}

void pwm_stop(int pwm_pin)
{
    pinMode(pwm_pin,OUTPUT);
    softPwmCreate(pwm_pin,0,200);
    softPwmWrite(pwm_pin,5);
    delay(1000);
    softPwmStop(pwm_pin);
}

